using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (IsValidUser())
        {
            //FormsAuthentication.RedirectFromLoginPage(txbUser.Text, cbRemeber.Checked);
            FormsAuthentication.SetAuthCookie(txbUser.Text, cbRemeber.Checked);
            if (Request.QueryString["ReturnURL"] != null)
            {
                Response.Redirect(Request.QueryString["ReturnURL"]);
            }
            else
            {
                Response.Redirect("admin/default.aspx");
            }
        }
        else
            lblMessage.Text = "Invalid user, sorry!";
    }
    protected bool IsValidUser()
    {
        dst_pbTableAdapters.pb_userTableAdapter userAdapter = new dst_pbTableAdapters.pb_userTableAdapter();
        DataTable user = userAdapter.GetActiveUserDataByUserId(txbUser.Text);
        string userpass = user.Rows[0]["user_pass"].ToString();
        if (user.Rows[0]["user_pass"].ToString() == txbPass.Text.ToString())
            return true;
        else
            return false;
    }
}
